<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ include file="/page/share/taglib.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
	<head>
		<base href="<%=basePath%>">

		<title>用户登陆</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
<style type="text/css">
.code {
	<!--background-image: url(code.jpg);-->
	font-family: Arial;
	font-style: italic;
	color: Red;
	border: 0;
	padding: 2px 3px;
	letter-spacing: 3px;
	font-weight: bolder;
}

.unchanged {
	border: 0;
}
div.hide {
    display: none;
}
</style>
		<script language="javascript" type="text/javascript">
	var code; //在全局 定义验证码
	function createCode() {
		code = "";
		var codeLength = 6;//验证码的长度
		var checkCode = document.getElementById("checkCode");
		var selectChar = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C',
				'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
				'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');//所有候选组成验证码的字符，当然也可以用中文的

		for ( var i = 0; i < codeLength; i++) {

			var charIndex = Math.floor(Math.random() * 36);
			code += selectChar[charIndex];

		}
		//        alert(code);
		if (checkCode) {
			checkCode.className = "code";
			checkCode.value = code;
		}

	}

	function validate() {
	
		var inputCode = document.getElementById("input1").value;
		if (inputCode.length <= 0) {
			alert("请输入验证码！");
			return false;
		} else if (inputCode.toUpperCase()!=code) {
			alert("验证码输入错误！");
			createCode();//刷新验证码
			return false;
		}
		return true; 
	}
</script>

	</head>
<%--	<body>

		<form method="post" action="login.action" onsubmit="return validate()">
			用户名： &nbsp;
			<input type="text" name="userName" size="10">
			<br>
			密码： &nbsp; &nbsp;
			<input type="password" name="password" size="10">
			<br>
            角色： &nbsp;&nbsp;
            <input type="text" name="groupName" size="10" value="admin">
            <br>
			&lt;%&ndash;验证码：&nbsp;
			<input type="text" id="input1" name="input1" onclick="createCode()"
				size="6" />
			<input type="text" id="checkCode" class="unchanged"
				style="width: 80px" />
			<br>&ndash;%&gt;
			<input name="denglu_tijiao" type="submit" value="确认" />
			<input name="denglu_chongzi" type="reset" value="重置" />
		</form>
		<br>
	</body>--%>
    <body>
        <h2>登陆界面</h2>
        <div class="error ${param.error == true ? '' : 'hide'}">
            登陆失败<br>
            ${sessionScope['SPRING_SECURITY_LAST_EXCEPTION'].message}
        </div>

        <form method="post" action="${pageContext.request.contextPath}/j_spring_security_check" >
            用户名：
            <input id="j_username" type="text" tabindex="1"  name="j_username" value=""/><br/>
            密     码：
            <input id="j_password" type="password" tabindex="1"  name="j_password" value=""/><br/>
            <%--默认两周 依赖cookie--%>
            <input type="checkbox" name="_spring_security_remember_me" />两周之内不必登陆<br />
            <button type="submit">登 录</button>
            <button type="reset">重 置</button>
        </form>
    </body>
</html>
